﻿using CodeGenerator.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using CodeGenerator.Util;

namespace CodeGenerator.Template.Service
{
    public partial class Service_svc_cs : ITemplate
    {
        public MetaData Data { get; set; }
        public List<LookupClassModel> lookups { get; set; }
        public List<PickupListModel> pickuplist { get; set; }

        public bool IsLookup(string modelName)
        {
            if (lookups != null)
            {
                return lookups.Where(x => x.Name.Equals(modelName)).Any() ? true : false;
            }
            return false;
        }

        public ClassModel getLookupClassByLookupAttributeName(string attributeName)
        {
            ClassModel classModel = new ClassModel();
            if (Data.Models != null)
            {
                foreach (var model in Data.Models)
                {
                    if (model.Name.Equals(attributeName))
                    {
                        classModel = model;
                    }
                }
            }
            return classModel;
        }

        public string Filename
        {
            get { return "Service.svc.cs"; }
        }

        public bool IsGenerateOneTime { get { return true; } }
        public bool IsGenerateFolder { get { return false; } }
        public bool IsRequiredOnlyOneMember { get { return false; } }
        public GenerateStyle GenerateStyle { get { return GenerateStyle.Normal; } }

    }
}

